fix(expiry): rebuild pending-winnings reclaim with correct errors and TTL touches (Closes #397) - #464
Open
diahtech1 wants to merge 1 commit into
Open
Conversation
… TTL touches (Closes TevaLabs#397) Fix error semantics for reclaim_expired_pending_winnings that were confused in recent diffs. The function now returns three distinct errors: - ExpiryNotConfigured (78) when pending winnings expiry is disabled (0) - PendingWinningsNotFound (77) when no entry exists for the user - PendingWinningsNotExpired (79) when the entry has not yet reached the configured age threshold Also fixes a critical error discriminant collision where PendingWinningsNotExpired shared value 66 with OracleTimestampOutsideWindow. PendingWinningsNotExpired is now 79. Changes: - contracts/src/errors.rs: move PendingWinningsNotExpired from 66 to 79 - contracts/src/admin.rs: add _extend_persistent_ttl on expiry key, pending winnings key, and updated-at key before reading them; update doc comment to document the three distinct errors - contracts/src/tests/pending_winnings_expiry.rs: fix wrong error expectations (NoActiveRound -> ExpiryNotConfigured/PendingWinningsNotFound), add test_reclaim_fails_when_expiry_disabled_after_enable and test_reclaim_fails_for_premature_reclaim - bindings/src/index.ts: fix wrong discriminants for EpochBudgetExceeded, OracleNotLive, InvalidPayoutPolicy; add RotationDelayNotElapsed, OracleTimestampOutsideWindow, and all missing error codes 70-79 - docs/WALLET_ERROR_GUIDE.md: add 14 missing error codes (55, 62-79), fix malformed table lines 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rebuilds
reclaim_expired_pending_winningswith correct error semantics and TTL touch behavior. The error meanings were confused in recent diffs — tests expectedNoActiveRoundfor conditions that should have distinct, descriptive errors.What changed
Critical fix: error discriminant collision
PendingWinningsNotExpiredshared discriminant66withOracleTimestampOutsideWindow. MovedPendingWinningsNotExpiredto79(next available slot) to resolve the collision.Reclaim function (
contracts/src/admin.rs)ExpiryNotConfigured(78) — expiry is disabled (value is 0 or absent)PendingWinningsNotFound(77) — no pending winnings entry for the userPendingWinningsNotExpired(79) — entry exists but has not yet reached the age thresholdget_pending_winningsbehaviorTests (
contracts/src/tests/pending_winnings_expiry.rs)test_reclaim_fails_when_expiry_disabled:NoActiveRound→ExpiryNotConfiguredtest_reclaim_fails_for_nonexistent_pending:NoActiveRound→PendingWinningsNotFoundtest_reclaim_fails_when_expiry_disabled_after_enable: enables expiry, disables it, verifiesExpiryNotConfiguredtest_reclaim_fails_for_premature_reclaim: tests age threshold at 200, 400, 499 (allPendingWinningsNotExpired), then 600 (succeeds)Bindings (
bindings/src/index.ts)EpochBudgetExceeded(66→67),OracleNotLive(66→68),InvalidPayoutPolicy(67→69)RotationDelayNotElapsed(55),OracleTimestampOutsideWindow(66), and all codes 70–79Documentation (
docs/WALLET_ERROR_GUIDE.md)Files changed
contracts/src/errors.rsPendingWinningsNotExpired66 → 79contracts/src/admin.rscontracts/src/tests/pending_winnings_expiry.rsbindings/src/index.tsdocs/WALLET_ERROR_GUIDE.mdAcceptance criteria
Closes Rebuild: pending-winnings expiry reclaim with precise errors #397